package main

import "fmt"

func binarySearch(array []int, n int, target int) (index int) {

	l := 0
	r := n

	for l <= r {
		mid := (l + r) / 2

		if array[mid] == target {
			return mid
		}

		if target < array[mid] {
			r = mid - 1
		} else {
			l = mid + 1
		}
	}

	return -1

}


func main()  {

	array := []int{1, 3, 5, 7, 9, 11, 13}

	fmt.Println(binarySearch(array, len(array), 8))

}